<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">个人注册</block>
		</cu-custom>
		<view class="register">

			<view class="content">
				<!-- 主体 -->
				<view>
					<uni-forms :value="formData" labelWidth="130" labelPosition="top" ref="form">
						<uni-forms-item required label="姓名" name="name">
							<uni-easyinput type="text" v-model="formData.name" placeholder="请输入姓名" />
						</uni-forms-item>
						<uni-forms-item required name="idcardNo" label="身份证号码">
							<uni-easyinput type="text" v-model="formData.idcardNo" placeholder="请输入身份证号码" />
						</uni-forms-item>
						<uni-forms-item required name="pic" label="身份证上传">

							<div style="display: flex;flex-wrap: wrap;">
								<view class="uploader">
									<text>点击上传身份证正面</text>
									<image mode="widthFix" src="https://img.xiaopiu.com/userImages/img2470177c89f8328.png"></image>
								</view>
								<view class="uploader">
									<text>点击上传身份证反面</text>
									<image mode="widthFix" src="https://img.xiaopiu.com/userImages/img2499177c8a0ac08.png"></image>
								</view>
							</div>

						</uni-forms-item>
						<uni-forms-item required name="telphone" label="手机号码">
							<uni-easyinput type="text" v-model="formData.telphone" placeholder="请输入手机号码" />
						</uni-forms-item>
						<uni-forms-item required name="address" label="送货地址">
							<uni-easyinput type="text" v-model="formData.address" placeholder="请输入送货地址" />
						</uni-forms-item>
						<uni-forms-item required name="shopAddress" label="门店地址">
							<uni-easyinput type="text" v-model="formData.shopAddress" placeholder="请输入门店地址" />
						</uni-forms-item>
					</uni-forms>

					<wButton text="注册" :rotate="isRotate" @click.native="startReg()"> </wButton>

					<!-- 底部信息 -->
					<view class="footer">
						<text @tap="isShowAgree" class="cuIcon" :class="showAgree?'cuIcon-radiobox':'cuIcon-round'">同意</text>
						<!-- 协议地址 -->
						<navigator url="" open-type="navigate">《客户服务协议》</navigator>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import wInput from "@/components/watch-login/watch-input.vue"; //input
	import wButton from "@/components/watch-login/watch-button.vue"; //button

	export default {
		components: {
			wInput,
			wButton,
		},
		data() {
			return {
				formData: {
					telphone: '',
					address: '',
					shopAddress: ''
				},
				showAgree: true, //协议是否选择
			}
		},
		methods: {
			startReg: function() {

				this.accesstoken = 'test';
				this.user_id = 1;
				
				this.userInfo = {
				  // nickName: this.phoneData,
				  nickName: '小同学',
				  language: "zh_CN",
				  avatarUrl:
				    "https://imgt1.oss-cn-shanghai.aliyuncs.com/ecAllRes/images/missing-face.png"
				};
				
				uni.setStorageSync("userInfo", this.userInfo);
				uni.setStorageSync("accesstoken", this.accesstoken);
				uni.setStorageSync("user_id", this.user_id);
				// #ifdef MP-WEIXIN
				uni.setStorageSync("tagtype", "weixin");
				// #endif
				// #ifdef MP-ALIPAY
				uni.setStorageSync("tagtype", "alipay");
				// #endif
				// #ifdef H5
				uni.setStorageSync("tagtype", "general");
				// #endif
				uni.showToast({
					title: "注册成功",
					duration: 1000
				})
				setTimeout(function() {
					uni.switchTab({
						url: "/pages/my/main"
					})
				}, 1000)
			}
		}
	}
</script>

<style lang='scss' scoped>
	@import url("../../components/watch-login/css/icon.css");
	@import "./style";
</style>
